package com.chennan.elasticjob.domain.service;

import com.chennan.rebbitmq.leading.producer.MyStreamOutput;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

import java.util.UUID;

/**
 * @author chennan
 * @createTime 2021年07月08日 16:01:00
 */
//@Component
public class RabbitSendJobService implements SimpleJob {

    @Autowired
    private MyStreamOutput myStreamOutput;

    @Override
    public void execute(ShardingContext shardingContext) {
        String msg="定时任务开始发送消息到rabbitMQ"+shardingContext.getJobName()+ UUID.randomUUID();
        System.out.println(msg);
        boolean send = myStreamOutput.dataToExcelFastOutput().send(MessageBuilder.withPayload(msg).
                setHeader("headerTag", "111111").build());
        System.out.println("已经发送！！"+send);
    }
}
